﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Velocity4Net.Ctx;
using Velocity4Net.Util.Introspection;

namespace Velocity4Net.App.Events
{
    /**
     * Defines the execution strategy for invalidGetMethod
     */
    class InvalidGetMethodExecutor : EventHandlerMethodExecutor
    {
        private IContext context;
        private String reference;
        private Object _object;
        private String property;
        private Info info;

        private Object result;

        public InvalidGetMethodExecutor(
                IContext context,
                String reference,
                Object _object,
                String property,
                Info info)
        {
            this.context = context;
            this.reference = reference;
            this._object = _object;
            this.property = property;
            this.info = info;
        }

        /**
         * Call the method invalidGetMethod()
         *  
         * @param handler call the appropriate method on this handler
         */
        public void execute(EventHandler handler)
        {
            result = ((InvalidReferenceEventHandler) handler).invalidGetMethod(
                    context, reference, _object, property, info);
        }

        public Object getReturnValue()
        {
            return result;
        }

        public bool isDone()
        {
            return (result != null);
        }
    }
}
